<?php
namespace BoxSns\Logic;
class WechatLogic extends \LogicController
{

    public function _initialize()
    {
        parent::_initialize();
        $param = array(
            'token' => $this->storeInfo['token'],
            'appID' => $this->storeInfo['appID'],
            'appsecret' => $this->storeInfo['appsecret'],
        );
        $this->wechatObj = new \Common\Org\weiXin($param);
    }

    /***********调用微信的js***/
    public function wxJs($list)
    {
        $this->signPackage = $this->wechatObj->GetSignPackage();
        $this->display(BOX_PATH . "/Common/Tpl/wxJs.tpl");
    }

    /********发送通过微信发一条文本信息到用户手****/
    public function send($user_id, $from_user_id, $content)
    {
        $user_info = D("SystemMember")->load($user_id);
        $from_user_info = D("SystemMember")->load($from_user_id);
        $r = wx_text($user_id, $content);
        /*******如果信息发送不成功啊，就是有48小时没有互动了，那么就提醒他****/
        if ($r['errcode'] == "45015") {
            $title = $from_user_info['nickname'] . "有话想对你说";
            $content = "私信内容:" . $content . "【搭理TA，请回复数字：“" . $from_user_info['user_id'] . "】";
            $r = wx_msg($title, $user_id, "boxPHP私信提醒", $content, $url);
        }
        return $r;
    }


}
  
  